package com.bit.bit_forum.controller;

import com.bit.bit_forum.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@Api(tags = "TestController 测试接口")
@RestController
@RequestMapping("/test")
public class TestController {

//    @ApiOperation("测试接口1")
    @RequestMapping("/hello")
    public String hello(){
        return "hello forum";
    }
//    测试异常处理
//    @ApiOperation("测试接口2")
    @GetMapping("/exception")
    public String testException() throws Exception {
        throw new Exception("这是一个Exception");
    }

//    测试自定义异常处理
    @GetMapping("/appException")
    public String testAppException() throws Exception {
        throw new ApplicationException("这是一个自定义 ApplicationException");
    }

//    @ApiOperation("测试接口4,请传入姓名")
//    @RequestMapping("/hello2")
//    public String helloByName(@ApiParam("姓名") String name){
//        return "name: "+name;
//    }

}
